<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<div id="">
			我是新页面
		</div>
		<!-- <button type="button" onclick="btn()">我是返回按钮</button> -->
		<button onclick="btn(890)"></button>
		<script type="text/javascript">
			let obj = {
				list: [1,2]
			}
			let newName = ''
			Object.defineProperty(obj, 'list', {
				set: (value) => {
					if (newName !== value) {
						console.log('我是设置值得时候查看的')
						newName = value
						console.log(value, 111111,)
					}
				},
				get: () => {
					console.log("我是取值的时候查看的")
					return newName
				}
			})

			function btn(name) {
				obj.list = [333]
				console.log(obj.list,"obj.nameobj.name")
			}
			
			let ulDom = document.createElement("div")
			ulDom.id = "domId"
			ulDom.style = {
				color: 'red',
				display: 'flex'
			}
			for (let i = 0; i < 5; i++) {
				const newLi = document.createElement("div")
				newLi.onclick = add
				newLi.innerText = "我是第" + i + "元素"
				newLi.obg = {
					name: i
				}
				ulDom.appendChild(newLi)
			}

			function handle() {
				for (let i = 0; i < ulDom.childNodes.length; i++) {
					ulDom.childNodes[i].style.color = 'black'
				}
			}
			ulDom.addEventListener("click", (e) => {

				handle()
				const _this = e.target

				if (e.target.tagName.toLowerCase() === 'div') {
					_this.style.color = 'red'
				}
			})

			function add(e) {
				const parentList = e.target.parentNode.childNodes
				console.log(e.target.obg)
				const index = Array.prototype.indexOf.call(parentList, e.target);
				// e.target.parentNode.removeChild(e.target.parentNode.childNodes[index])
				console.log(index)

			}
			document.body.appendChild(ulDom)
		</script>
	</body>
</html>
